package net.nshc.kwkim.mycalc;

public class StackArray {
	
	public Object firstStack[];
	public int top;
	
	public StackArray(int size){
		firstStack = new Object[size];
		top = -1;
	}

	public Object getItem(int index){
		return firstStack[index];
	}

	public void push(Object ele){
		firstStack[++top] = ele;
	}

	public Object peek(){
		return firstStack[top];
	}

	public Object pop(){
		try{
			return firstStack[top--];
		}catch(ArrayIndexOutOfBoundsException e){
			top++;
			return "error";
		}
		
	}

}